package com.xing.binbackend.pattern.responsibility.operation.approve;

// 具体实现：大额采购审批
public class PurchaseApproval extends ApprovalWorkflow {
    @Override
    protected void validate(Request request) {
        if (request.getAmount() > 1000000) {
            throw new IllegalArgumentException("超出单笔采购限额");
        }
    }

    @Override
    protected void sequentialApproval(Request request) {
        System.out.println("部门经理审批 → 财务审批");
    }

    @Override
    protected void parallelApproval(Request request) {
        System.out.println("并发执行：法务审核合同 + 采购委员会审批");
    }

    @Override
    protected boolean needParallelApproval() {
        return getCurrentRequest().getAmount() > 500000; // 50万以上触发并行审批
    }

    private Request getCurrentRequest() {
        return new Request();
    }

    @Override
    protected void preProcess(Request request) {
        System.out.println("自动关联历史采购记录...");
    }
}
